<%@page import="java.util.List"%>
<%@page import="com.jfinal.plugin.activerecord.Page"%>
<%@page import="com.hongye.app.model.RoleModel"%>
<%@page import="com.hongye.app.model.AuthorModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"
    pageEncoding="UTF-8"%>
<%  RoleModel roledetail=(RoleModel)request.getAttribute("roledetail"); %>
<%  String authname=(String)request.getAttribute("authname"); %>
<!doctype html>
<html class="fixed">
	<head>
		<!-- Basic -->
		<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="keywords" content="HTML5 Admin Template" />
		<meta name="description" content="Porto Admin - Responsive HTML5 Template">
		<meta name="author" content="okler.net">
		<!-- Mobile Metas -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<!-- Vendor CSS -->
		<link rel="stylesheet" href="../admin/css/bootstrap.css" />
		<link rel="stylesheet" href="../admin/css/font-awesome/css/font-awesome.css" />
        <link rel="stylesheet" href="../admin/css/select2.css" />
		<!-- Theme CSS -->
		<link rel="stylesheet" href="../admin/css/theme.css" />
		<!-- Skin CSS -->
		<link rel="stylesheet" href="../admin/css/default.css" />
		<!-- Theme Custom CSS -->
		<!-- Theme Custom ../admin/css -->
		<script src="../admin/js/modernizr.js"></script>
	</head>
	<body>
		<section role="main" class="content-body" style="margin-top: 50px;">
			<!-- start: page -->
			<section class="panel">
				<header class="panel-heading">
					<h2 class="panel-title">角色修改-详情</h2>
				</header>
				<div class="panel-body">
					<div class="panel-body">
						<p class="lead"> <span class="alternative-font"><%=roledetail.get("r_name") %></span> </p>
						角色名称：<input id="rolename" type="text" name="rolename" value="<%=roledetail.get("r_name") %>" />
						权限名称：<select id="authselect" onchange="" style="width:150px; ">
								<% List<AuthorModel> authorlist=(List)request.getAttribute("authorlist");
									for(int i=1;i<=authorlist.size();i++){
										AuthorModel author = authorlist.get(i-1);
								%>
					                   <option selected><%=author.get("auth_name")%></option>
					              <%} %>
				                  </select>
						<a  class="btn btn-facebook mb-md ml-xs mr-xs" onclick="editrole();" >提交修改 </a>
             		 	<a  href="../admin/roleView" class="btn btn-facebook mb-md ml-xs mr-xs" onclick="addrolehid();">取消</a>
					</div>
				</div>
			</section>
		<!-- Specific Page Vendor -->
		<!-- Vendor -->
		<script src="../admin/js/jquery.js"></script>
		<!-- Theme Base, Components and Settings -->
		<script src="../admin/js/theme.js"></script>
		<!-- Theme Custom -->
		<script src="../admin/js/theme.custom.js"></script>
		<!-- Theme Initialization Files -->
		<script src="../admin/js/theme.init.js"></script>
		<!-- Examples -->
		<script src="../admin/js/tables/examples.datatables.default.js"></script>
		<script src="../admin/js/tables/examples.datatables.row.with.details.js"></script>
		<script src="../admin/js/tables/examples.datatables.tabletools.js"></script>
		<script type="text/javascript">
		 window.onload = function (){ 
		     $("#authselect").val('${authname}');
		} 
		//修改
		function editrole(){
			var id = ${id};
			var rolename = $("#rolename").val();
			var authname = $("#authselect").val(); 
			$.get('../admin/editRole?rolename='+rolename+'&authname='+authname+'&id='+id,function(data){
				if(data=='suc'){
					location.href='../admin/roleView';
				}else if(data=='fal'){
					alert('添加失败!');
				}else if(data=='exist'){
					alert('该角色存在！');
				}
			});
		}
		</script>
	</body>

</html>